package com.guigu.servicesystem.mapper;

import com.guigu.servicesystem.entity.TbAdmin;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.guigu.servicesystem.entity.vo.Admin_role;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author testjava
 * @since 2020-07-09
 */
public interface TbAdminMapper extends BaseMapper<TbAdmin> {
    @Select("SELECT a.id,a.login_name,a.password,a.status,c.name,c.id AS role_id FROM tb_admin a,tb_admin_role b,tb_role c WHERE a.id=b.admin_id AND b.role_id =c.id AND a.`status`=#{status} ")
    List<Admin_role> selectAllAdmin_Role(int status);
    @Select("SELECT a.id,a.login_name,a.password,a.status,c.name,c.id AS role_id FROM tb_admin a INNER JOIN tb_admin_role b ON a.id =b.admin_id JOIN tb_role c ON b.role_id=c.id WHERE a.id=#{id}")
    Admin_role findbyAdmin(@Param("id") int id);

}
